package com.tuo51.evaluate.domain.etc;

import com.tuo51.foudation.model.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

@Entity
@Data
@Table(name = "login_record")
@EqualsAndHashCode(callSuper = true)
public class LoginRecord extends Model {

    @Column(columnDefinition = "int default 1 COMMENT '1:web 2:pad 3:app'")
    private Integer loginChannel;

    @Column(columnDefinition = "varchar(50) COMMENT '登录ip'")
    private String loginIp;

    @Column(columnDefinition = "varchar(32) COMMENT '登录人'")
    private String staffId;

    @Column(columnDefinition = " datetime DEFAULT NOW() COMMENT '创建时间' ")
    private Date created = new Date();

    public static LoginRecord of(Integer loginChannel, String loginIp, String staffId, Date created){
        LoginRecord record = new LoginRecord();
        record.setLoginChannel(loginChannel);
        record.setLoginIp(loginIp);
        record.setStaffId(staffId);
        record.setCreated(created);
        return record;

    }
}
